package org.javaongems.client.tool;

import org.javaongems.client.BasicStaticClientGemlet;
import org.javaongems.client.forms.TForm;
import org.javaongems.client.stdctrls.Label;
import org.javaongems.client.vcl.Control;
import org.javaongems.client.vcl.ControlListenerAdapter;
import org.javaongems.client.vcl.MountPane;

public class GemsVisualComponentBuilder extends BasicStaticClientGemlet {
	private BtnListener listener = new BtnListener();
	private MountPane container, bodyContainer;
	private TestPanel gemsPanel = new TestPanel();
	private TForm test;
	
	public void initialiseView() {
		bodyContainer = MountPane.get(null);
		container = MountPane.get("slot1");
		container.insertComponent(gemsPanel);
		gemsPanel.btn1.setControlListener(listener);
		gemsPanel.btn2.setControlListener(listener);
	}
	
	private class BtnListener extends ControlListenerAdapter {
		public void onClick(Control sender) {
			if (sender == gemsPanel.btn1)
				createForm();
			else 
				other();
		}

		private void createForm() {
			test = new TForm();
			test.setParent(bodyContainer);
			test.setCaption("Lunatic");
//			test.setBorderStyle(TForm.BS_SIZETOOLWIN);

			Label lbl = new Label();
			lbl.setParent(test);
			lbl.setText("I see that there is nearly 4px of spacing between TreeItems in a tree. This is occupying lots of space in my panel. I want to remove this spacing between TreeItems. "); 
			lbl.setAlign(Label.ALIGN_CLIENT);
		}
		
		private void other() {
			test.setFocus();
		}
	}
	
}



/*  

			
//			Element elm = sender.getElement();
//			String _name = GWT.getTypeName(sender);
//			Element elm1 = gemsPanel.btn1.getElement(); 
//			String s;
//			s = DOM.getStyleAttribute(elm, "backgroundColor");
//			if (sender == gemsPanel.btn1) {
//				DOM.setStyleAttribute(elm, "backgroundColor", "#7596c6");
//			} else 
//				DOM.setStyleAttribute(elm1, "backgroundColor", "");
			
//			ComponentWriter wrtr = new JsonComponentWriter();
//			wrtr.writeRootContainer(gemsPanel);
//			String text = wrtr.toString();
//			System.out.println(text);


*/